package com.example.carrierapp.ui.main.dispatch.detail.delivery

import android.os.Bundle
import com.example.carrierapp.base.DatabindingFragment
import com.example.carrierapp.config.ConstValue
import com.example.carrierapp.viewmodel.viewmodel.DispatchDeliverModel
import com.example.lb.fingerdemo.R

class DispatchDeliveryFragment_New : DatabindingFragment<DispatchDeliverModel, DispatchDeliveryContract.View, DispatchDeliveryPresenter>(), DispatchDeliveryContract.View {

    override fun createPresenter() = DispatchDeliveryPresenter(context!!)

    override fun getLayout() = R.layout.fragment_dispatch_delivery_new

    override fun initData() {
        mPresenter.attachView(this)
        arguments?.let {
            model.id = it.getInt(ConstValue.ID, 0)
        }
        showProgress()
        mPresenter.getDispatchDetail(model.id)
    }

    companion object {
        fun newInstance(id: Int, showOpera: Boolean): DispatchDeliveryFragment_New {
            val args = Bundle()
            args.putInt(ConstValue.ID, id)
            args.putBoolean(ConstValue.SHOW_OPERA, showOpera)
            val homeFragment = DispatchDeliveryFragment_New()
            homeFragment.arguments = args
            return homeFragment
        }
    }

    override fun getDispatchDetailSuccess(bean: DispatchDeliverModel) {
        dismissProgress()
        notifyModel(bean)
    }

    override fun getDispatchDetailFailde(msg: String?) {
        dismissProgress()
    }
}